Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
    Bookmark Topic Watch Topic
  • New Topic