Forums Register Login

Sitemesh: make page load fast by putting JavaScript in the page bottom?

+Pie Number of slices to send: Send
I am using Spring MVC plus Sitemesh for a project. But my question should not be relevant to Spring.

I have a main decoator page, which has a few external JavasScript files to be used for all pages.
Specific pages may have external JavaScript files just their pages and these JavaScript files depend on the JavaScript files listed in the main decorator.

If I put these JavaScript in the <head> section (this is the way probably most people do), then the generated page will have all JavaScript listed in the order of JavaScript files from the main decorator, followed by JavaScript files specified in specific pages. All this works well.

Now I would like to implement one of the best practices for improvingt page loading performance, which is about putting JavaScript in the bottom of a page, close to the closing body tag.

I dont know how to do this wth Sitemesh in case of decorator and individual pages both having JavaScript files that have dependence. Googled and thought about, cannot find or figure out the solution. Not sure whether it is possible.

The main decorator uses <decorator:body /> to include content from individual pages. Putting the JavaScript in the main decorator before or after <decorator:body /> has no use.

Any help is really appreciated.

Regards.
+Pie Number of slices to send: Send
I was just thinking about doing the same thing. I am not sure if its possible but I was thinking that using SiteMesh's content block feature could work for this. Have you had any success?
+Pie Number of slices to send: Send
Found out how to do this.

1. In sitemesh.xml make sure you are using the HTML parser not the fast parser.
2. Do something like this

Let nothing stop you! Not even this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 3032 times.
Similar Threads
Sitemesh 2.4 and SpringMVC 2.5.6
Struts2 Action/OGNL in SiteMesh decorator
Spring MVC redirect with sitemesh
SiteMesh + Render External Pages
JSF/MyFaces and Sitemesh
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:38:21.