aspose file tools*
The moose likes Other Open Source Projects and the fly likes Sitemesh: make page load fast by putting JavaScript in the page bottom? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Sitemesh: make page load fast by putting JavaScript in the page bottom? " Watch "Sitemesh: make page load fast by putting JavaScript in the page bottom? " New topic
Author

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

David Last
Greenhorn

Joined: Apr 28, 2011
Posts: 1
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.
J.K. Sloan
Greenhorn

Joined: Jul 12, 2011
Posts: 2
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?
J.K. Sloan
Greenhorn

Joined: Jul 12, 2011
Posts: 2
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

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Sitemesh: make page load fast by putting JavaScript in the page bottom?