fusebox.head.addCSS and CDNs

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

fusebox.head.addCSS and CDNs

Doug Hall-6
I'm converting from an old Active4D 4.5 site to the latest version (6.4r3
as I understand it). I noticed that this no longer downloads :

  fusebox.head.addCSS($fusebox;"//
cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.35.4/css/bootstrap-dialog.min.css
")

If you'll check the actual URL, you'll see that it's fine. The generated
html from the page source looks the same, too. Is there something else I'm
not thinking about that could stop the download? This is the only place on
my site where I'm downloading CSS from a CDN. I know I could serve it
locally, and it is really small, but I thought it might be abit faster from
a CDN. Any "best practice" advice on this would be welcomed, too.

Thanks,
Doug Hall
_______________________________________________
Active4D-dev mailing list
[hidden email]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/
Reply | Threaded
Open this post in threaded view
|

Re: fusebox.head.addCSS and CDNs

Aparajita Fishman
Depending on the rest of your site, the difference in latency between the CDN request and a request to your server is probably so minimal compared to the overall load time it really isn’t worth it, especially when you consider that it’s being cached by the browser.

In any case, fusebox.head.addCSS is meant for accessing *local* files. I guess that method must have changed between v4.5 and v5, because as it is now it would never work.

If you are always loading that css, there is no point in using fusebox.head.addCSS, just put it directly in the <head> of the layout. If you are only loading that css in certain circuits, then you should still probably put it in the layout, but put surround it with a test for the circuit (check $fusebox{“circuit”}).

Otherwise, if you’re determined to use fusebox.head.addCSS for an external stylesheet, you have to do it like this:

fusebox.head.addCSS($fusebox; "!<link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.35.4/css/bootstrap-dialog.min.css\ <https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.35.4/css/bootstrap-dialog.min.css%5C>" />")


> On Jun 14, 2017, at 8:33 AM, Doug Hall <[hidden email]> wrote:
>
> I'm converting from an old Active4D 4.5 site to the latest version (6.4r3
> as I understand it). I noticed that this no longer downloads :
>
>  fusebox.head.addCSS($fusebox;"//
> cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.35.4/css/bootstrap-dialog.min.css
> ")
>
> If you'll check the actual URL, you'll see that it's fine. The generated
> html from the page source looks the same, too. Is there something else I'm
> not thinking about that could stop the download? This is the only place on
> my site where I'm downloading CSS from a CDN. I know I could serve it
> locally, and it is really small, but I thought it might be abit faster from
> a CDN. Any "best practice" advice on this would be welcomed, too.
>
> Thanks,
> Doug Hall
> _______________________________________________
> Active4D-dev mailing list
> [hidden email]
> http://list.aparajitaworld.com/listinfo/active4d-dev
> Archives: http://active4d-nabble.aparajitaworld.com/

_______________________________________________
Active4D-dev mailing list
[hidden email]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/
Reply | Threaded
Open this post in threaded view
|

Re: fusebox.head.addCSS and CDNs

Doug Hall-6
Local it is! Incidentally, the javascript equivalent
fusebox.head.addJS($fusebox;"//...) loads a CDN-based javascript file just
fine. On the surface, it appears that these two methods should work the
same way.

To me, CDNs are a mixed blessing. On the one hand, it offloads at least a
portion of your site to a different host. Typically, we get a lot of
first-time users, so caching isn't a game-changer. Also, since some web
browsers have (at least historically) been limited to downloading no more
than 2 outstanding requests per hostname, using a CDN bypasses that
limitation. Also, it's easier to simply change a URL than to download yet
another CSS or javascript file that I'm not responsible for updating. On
the flips side, CDNs are not created equally. Some may go out of business
or decide not to host your (older?) version of a CSS/Javascript file,
causing your site to break unexpectedly.

Thanks,
Doug


On Wed, Jun 14, 2017 at 12:24 PM, Aparajita Fishman <[hidden email]
> wrote:

> Depending on the rest of your site, the difference in latency between the
> CDN request and a request to your server is probably so minimal compared to
> the overall load time it really isn’t worth it, especially when you
> consider that it’s being cached by the browser.
>
> In any case, fusebox.head.addCSS is meant for accessing *local* files. I
> guess that method must have changed between v4.5 and v5, because as it is
> now it would never work.
>
> If you are always loading that css, there is no point in using
> fusebox.head.addCSS, just put it directly in the <head> of the layout. If
> you are only loading that css in certain circuits, then you should still
> probably put it in the layout, but put surround it with a test for the
> circuit (check $fusebox{“circuit”}).
>
> Otherwise, if you’re determined to use fusebox.head.addCSS for an external
> stylesheet, you have to do it like this:
>
> fusebox.head.addCSS($fusebox; "!<link rel=\"stylesheet\" type=\"text/css\"
> href=\"https://cdnjs.cloudflare.com/ajax/libs/
> bootstrap3-dialog/1.35.4/css/bootstrap-dialog.min.css\ <
> https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.
> 35.4/css/bootstrap-dialog.min.css%5C>" />")
>
>
> > On Jun 14, 2017, at 8:33 AM, Doug Hall <[hidden email]> wrote:
> >
> > I'm converting from an old Active4D 4.5 site to the latest version (6.4r3
> > as I understand it). I noticed that this no longer downloads :
> >
> >  fusebox.head.addCSS($fusebox;"//
> > cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.35.4/
> css/bootstrap-dialog.min.css
> > ")
> >
> > If you'll check the actual URL, you'll see that it's fine. The generated
> > html from the page source looks the same, too. Is there something else
> I'm
> > not thinking about that could stop the download? This is the only place
> on
> > my site where I'm downloading CSS from a CDN. I know I could serve it
> > locally, and it is really small, but I thought it might be abit faster
> from
> > a CDN. Any "best practice" advice on this would be welcomed, too.
> >
> > Thanks,
> > Doug Hall
> > _______________________________________________
> > Active4D-dev mailing list
> > [hidden email]
> > http://list.aparajitaworld.com/listinfo/active4d-dev
> > Archives: http://active4d-nabble.aparajitaworld.com/
>
> _______________________________________________
> Active4D-dev mailing list
> [hidden email]
> http://list.aparajitaworld.com/listinfo/active4d-dev
> Archives: http://active4d-nabble.aparajitaworld.com/
_______________________________________________
Active4D-dev mailing list
[hidden email]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/