Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Update:  uPortal 4.1.0 Respondr supports the RENDER_HEADERS subphase so a portlet that chooses to can contribute markup for inclusion into the head section (see

Jira Legacy
serverJASIG Issue Tracker
serverId76221f40-4501-3df1-8578-6c87908cbdf7
keyUP-4046
).  However unless you are working on a framework portlet (e.g. a portlet that is part of uportal-war) you can't guarantee that the portal version your portlet is running on supports that feature so you should follow the above practice.

Content Distribution Networks (CDNs)

Some popular CSS libraries are hosted on CDNs.  To decrease load times (browser accesses a different domain) and potentially improve performance (a different application may have downloaded the CSS library from the CDN and have it in the browser's cache), a CDN can be used instead of obtaining the library from the Resource Server.  The CDN must support HTTPS to access the library so user's don't get security warnings.

When a portlet obtains a library from a CDN instead of the Resource Server, the library does not need to be mentioned in the maven-war-plugin in the portlet's pom.xml (don't need to have a local copy of the library overlaid into the portlet).

CDNs do have some disadvantages.  

  • They might make it more difficult to run uPortal off-line when you don't have a network connection and the browser doesn't have a cached version of the desired library.  You can work around this by temporarily modifying the source code, or creating an entry in your machine's hosts file and  hosting the javascript library locally (see below).
  • CSS hosted on the Resource Server in both non-minified and minified versions allow selecting the non-minified versions by disabling Aggregation in the uPortal Admin UI.  If scripts are listed in a skin.xml file and included with the <rs:aggregatedResources path="skin.xml"/> tag you do get minified or non-minified versions accordingly.

CDNs are recommended for the following CSS libraries.  Libraries referenced on CDNs should also be placed in the resource server so they are available when off-line in an emergency (see above).

  • Font Awesome

Resources from a CDN should use the resourceURL tag library to load them rather than accessing the CDNs directly.  This allows the URL to be modified to a non-minified version when JS aggregation is disabled or running in off-line mode (though the resourceURL tag currently does not do this).  E.g. access like:

 

<link rel="stylesheet" href="<rs:resourceURL value='//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css'/>" type="text/css"/>

CSS Scoping

You'll notice in the first example above in CSS Loading that immediately after the CSS <link> element is a div with a class name specific to the portlet web application. This div is used to scope all style rules created for the portlet.

...