What is a good position to place bundled files in HTML? #790
-
The Bundle extension will bundle css and js in the head, into a js and css file in the head. But some files (js) would be better placed at the end of the page before the closing body tag, because they are not needed until later in the page load. It would be nice if bundle extension had an additional data-attrubute to specify the location the final bundle file(s) should reside. This would allow the possibility of multiple bundle files created, to be included in the head or at the end of the page ( perhaps via $this->yellow->page->getExtra("footer") )
Website with unbundled CSS and JavaScript files:
Website with bundled CSS and JavaScript files:
Thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The bundle extension defers script loading, all javascripts will be executed as soon as the DOM is fully loaded. Therefore in most cases it shouldn't make a difference if you put some scripts in the body. Some js modules might need this for technical reasons, but this can be solved individually in each extension. For more information on this topic see also #289 |
Beta Was this translation helpful? Give feedback.
The bundle extension defers script loading, all javascripts will be executed as soon as the DOM is fully loaded. Therefore in most cases it shouldn't make a difference if you put some scripts in the body. Some js modules might need this for technical reasons, but this can be solved individually in each extension.
For more information on this topic see also #289