Skip to content
/ packtag Public

A JSP Taglib for delivering minified, combined and gzip-compressed resources (JavaScript and CSS).

License

Notifications You must be signed in to change notification settings

galan/packtag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

85578b1 · Jan 7, 2025
May 6, 2015
Jul 6, 2015
Dec 3, 2024
Dec 3, 2024
Dec 3, 2024
Apr 16, 2008
Jan 24, 2015
May 6, 2015
Jan 7, 2025
Dec 3, 2024
Dec 3, 2024

Repository files navigation

Build Status Maven Central License

pack:tag

A JSP Taglib for delivering minified, combined and gzip-compressed resources (JavaScript and CSS).

Usage

To use the taglib in a JSP, you have to declare it first:

<%@ taglib uri="https://github.com/d8bitr/packtag" prefix="pack" %>

(You can still use the old uri 'http://packtag.sf.net' for backward compatibility)

Now you can easily pack JavaScript by using the following tag:

<pack:script src="/js/myJavaScriptFile.js"/>

Accordingly for Cascading Style Sheets:

<pack:style src="/css/myCascadingStyleSheet.css"/>

You can enable and disable each tag individually by setting the attribute enabled to false, e.g.:

<pack:script src="/js/myJavaScriptFile.js" enabled="false"/>

You can combine resources simply by listing them up:

<pack:script>
  <src>/js/myJavaScriptFile.js</src>
  <src>/js/mySecondJavaScriptFile.js</src>
</pack:script>

That's it.

If you want to deepen your knowledge and learn about advanced techniques, I suggest reading "pack:tag - a packed guide to website performance optimization".

Integration

  1. Add the maven dependency to your project:

     <dependency>
         <groupId>de.galan.packtag</groupId>
         <artifactId>packtag-core</artifactId>
         <version>4.0.0</version>
     </dependency>
    
  2. Copy the <servlet> and <servlet-mapping> from the web.xml into your /WEB-INF/web.xml

Note

pack:tag is still supported, and still encouraged to be used if it makes sense for your project. But, no further development beyond bug fixes is expected. pack:tag is over 8 years old, and has been stable since then. Thank you to the community for your support of this project over the last years.