what would cause the parsing of jquery, jquery-ui and jsrequire to not be deferred?

i notice that when i load my site's theme (elgg 2.1), the jquery and other core JS modules are no longer parsed in a deferred way (according to the analysis tools at gtmetrix.com). even when i disable the lines in my theme that point the pages to a CDN to source the JS files, the result is the same.

(i also noticed while looking at the aalborg theme to see if i could learn any tricks, that the aalborg theme is using the pagesetup even that no longer functions in elgg 2.1).

  • as it turned out, the cause of this was having piwik's tracking script inline on the main html template. i have moved it to an AMD module now. i had no idea that inline JS would change the way that the other JS files were loaded, i thought that requireJS would be stricter than that and just put out an error message.

  • Pagesetup event should still work in 2.X. It will get removed in 3.X.

  • i found it doesn't work for me in 2.1 - so i have moved all pagesetups to the relevant system,init event. i didn't look into it any further than that - so it possibly does still work in 2.1, but there was some other issue. in particular river_addon would not run unless i did this.

  • jQuery, UI, the require config, RequireJS, and elgg.js are all regular (synchronous, not deferred) scripts. They don't block rendering because we keep them at the end of body. I don't know why another script somewhere else would make that much difference.

  • i don't either, but it definitely was the case that putting the standard piwik js file (which does not use jquery) in the page (at the bottom), caused the jquery files to be listed on the gtmetrix page as not being deferred. essentially they were loaded in the head, as i recall - not the bottom of the body.