Putting header items at the end of <body> is documented here:
https://ci.apache.org/projects/wicket/guide/8.x/single.html#_put_javascript_inside_page_body.
Like Sven I also personally dislike this kind of habit but we might
consider to make the overall configuration easier for it.
On 08/10/2017 11:06, Korbinian Bachl wrote:
Hi Sven,
in theory you are right - but with wicket ajax on page you get an inline script
like marting said.
The problem is that the ondomready scripts depend on jquery and wicket-xyz ones
and there is no way to defer them.
So, you never can defer the jQuery currently as its from wicket itself and same
is IMHO for the wicket js files.
The only way I can think of is to transfer the inline script into a base64 and
embedd it this way:
<script src="data:text/javascript;base64,.....encoded script..." defer></script>
Then the jQuery could be made defered - you can check it here:
https://stackoverflow.com/questions/41394983/how-to-defer-inline-javascript
However, I'm not sure yet that every browser works with this.
So the put to bottom is IMHO still the best way to do it. Or did I miss
something here?
Also what do you think on allowing to not use the wicket jQuery at all?
e.g.: getJavaScriptLibrarySettings().setJQueryReference(null);
Anyway, I think wicket should not block the rendering of the page by default,
especially as mobile is becoming the 50%+ audience nowadays.
Best,
Korbinian
----- Ursprüngliche Mail -----
Von: "Sven Meier" <s...@meiers.net>
An: dev@wicket.apache.org
Gesendet: Samstag, 7. Oktober 2017 22:22:56
Betreff: Re: wicket8 : wickets js/ jquery integration
Hi Korbinian,
using the "defer" attribute on script tags in the head section seems to
be best practice now:
https://www.shivering-isles.com/the-science-of-loading-javascript/
Wicket supports the attribute since
https://issues.apache.org/jira/browse/WICKET-5715
Have fun
Sven
Am 07.10.2017 um 19:49 schrieb Korbinian Bachl:
Hi,
currently wicket renders all its jQuery and Ajax stuff right into the head, and
I wonder why.
Current best practice seems to defer all javascript till the end of the page
just right before the closing </body> tag to let the browser meanwhile get the
DOM and do some work and not get blocked by loading resources. So wouldnt it
maybe with wicket 8 be a good time to change this?
e.g. Do
<body>
all the stuff
<script type="text/javascript"
src="../wicket/resource/org.apache.wicket.resource.JQueryResourceReference/jquery/jquery.js"></script>
<script type="text/javascript">
ajax stuff...
</script>
</body>
by default? and since mostly today jQuery is already on the page maybe even
allow to apply a null at the
getJavaScriptLibrarySettings().setJQueryReference(null); to not have a wicket
reference on it at all? Many webapps nowadays tend to only have 1 app.js that
includes everything as its often build by tools like webpack.
Would this be a good or bad idea?
Best,
Korbinian
PS: in wicket 8 jquery 2.x is interchangable with jquery 3.x, am I right?