Board index JavaServer Faces General How can I improve performance on the initial page load?

How can I improve performance on the initial page load?

Components, Ajax Framework, Utilities and More.


Posts: 15076
Location: Cybertron

Note: Charts ans Schedule are not aggregated in primefaces.js and primefaces.css.
PrimeFaces Lead


Posts: 283
optimus.prime wrote:
Note: Charts ans Schedule are not aggregated in primefaces.js and primefaces.css.

Right. But if they are included in JSF tree, but not rendered, these .js will still be included in generated HTML. I think non-core component resouces(not in primefaces.js/.css) should be included only when their encode() methods are called. Especially for home page that requires fast loading. Charts/schedule components will be shown in ajax way when user click some buttons, and the same JSF page is used. At this point, chart.js/schedule.js need to be included.
JSF components: PrimeFaces 5.0
JSF core: Mojarra 2.2.6
Glassfish 4, Tomcat 8
FireFox 28, IE 8, Chrome 24.0


Posts: 15076
Location: Cybertron

JSF handles resource management not PrimeFaces and it is quite tricky to implement what you ask for. If you add these components on the fly like in a conditional ui include PF will load them on the fly though using dynamic resource loading feature of ours.
PrimeFaces Lead

Oleg User avatar
Expert Member

Posts: 3713
Location: Russia, Siberia => Germany, Black Forest
Yes, conditional "src" in ui:include is a good approach. In general, dynamic resource inclusion is possible in JSF. We did this e.g. for CKEditor in PF Extensions. But in a common case it is also fine with standard JSF res. management. Static resource loading doesn't hirt for small resources. Dynamic approach makes sense for more or less big resources. CKEditor has e.g. MBs of resources and it makes sense don't load all them at once. Only on demand, if you change theme or similar.

How big are Chart and Schedule resources? I think the size is ok. Is it not?
PrimeFaces 4.x, 5.x, Mojarra 2.2.x, JBoss WildFly, WebSphere, Windows 8.1, IntelliJ IDEA
PrimeFaces Cookbook: http://ova2.github.com/primefaces-cookbook/ PrimeFaces Extensions on GitHub: http://primefaces-extensions.github.com/


Posts: 15076
Location: Cybertron

How big are Chart and Schedule resources? I think the size is ok. Is it not?

charts.js is 76kb, schedule.js is 20kb in showcase. Both are not in primefaces.js (40kb with 35+ most used components).
PrimeFaces Lead

Oleg User avatar
Expert Member

Posts: 3713
Location: Russia, Siberia => Germany, Black Forest
The size of these resources is quite ok for me. I can not see any reason to come up with some workarounds or implement tricky dynamic loading based on "rendered" attr. or whatever. It is not worth in my opinion.
PrimeFaces 4.x, 5.x, Mojarra 2.2.x, JBoss WildFly, WebSphere, Windows 8.1, IntelliJ IDEA
PrimeFaces Cookbook: http://ova2.github.com/primefaces-cookbook/ PrimeFaces Extensions on GitHub: http://primefaces-extensions.github.com/


Posts: 283
I am not sure how difficult it is to implement dynamic loading of resources. Some thoughts:

Take chart for instance,
1. use @vewScope variable to remember whether chart.js is included in the tree.
2. when a chart component is encoded, check the variable, add chart.js if not added yet.
So chart.js will be added before it is used by any chart component.
not necessary to add it in the head, just add it where the component is rendered.
This works for both ajax and non-ajax requests.
After chart.js is added, make sure it will not be removed by any subsequent ajax update.
3. if this simple approach works, it worths the effort to implement it.

Thanks,
Dave
JSF components: PrimeFaces 5.0
JSF core: Mojarra 2.2.6
Glassfish 4, Tomcat 8
FireFox 28, IE 8, Chrome 24.0


Posts: 43
Location: Salta, Argentina
Here is a good aproach how to Speed up Primefaces page load with p:remoteCommand partial update see
http://kahimyang.info/kauswagan/howto_blogs/1166-speed_up_primefaces_page_load_with_p_remotecommand_partial_update
Netbeans 8.0, Mojarra 2.1.26 , Primefaces 5, PrimeFaces Extensions 2.0.0, OmniFaces 1.8.1 , Glassfish 3.1.2.


Posts: 1
optimus.prime wrote:
JSF handles resource management not PrimeFaces and it is quite tricky to implement what you ask for. If you add these components on the fly like in a conditional ui include PF will load them on the fly though using dynamic resource loading feature of ours.


I understand it might be hard but is there any plan to split javascript loading by component?


Posts: 41
With PrimeFaces PRO, it's easy to support, tune and add features to PrimeFaces as if it were an in-house framework.

PrimeFaces PRO is a term based commercial support service. With the exclusive services of Pro account, you no longer need to post your questions in PrimeFaces community forum and your issues to community issue tracker.

Standard PRO Services

Access to pro.primefaces.org
Response at most in 1 business day.
Defect patches.
Private branch management in case you need.
Customized builds.
Unlimited number of cases.
Remote desktop connection.
Conference calls for discussions.
High priority to your issues.
Non PrimeFaces related general JSF assistance.

New Features

New feature and enhancement requests are not available in core services and provided via an hour based model instead. When you have a feature request we provide an estimate, if you confirm we deliver your request within an estimated timeframe and deduct the amount of work from your hours. These requests can be;

- New components.
- New functionality to existing components.
- Changing the way a certain functionality is implemented.
- Proof of Concept implementations of a use case.
- Code reviews to offer best practices.

Hourly rate is 200 usd and discounts apply on bulk purchases that are more than 50. You can purchase additional hours along with the subscription and also anytime during your subscription period. If your subscription term ends with unused hours, they will be added to your new subscription term in case you extend.

To get a quote, please contact us and mention the total number of developers who will be working in your PrimeFaces projects.

PreviousNext

Return to General