unpkg.com intergration for MODX Revolution

Syntax:

    
        [[unpkg.com?
            &packages=`{
                "link" : [
                    { "package" : "", "version" : "", "file" : "", "algo" : "", "crossorigin" : "" }
                ],
                "script" : [
                    { "package" : "", "version" : "", "file" : "", "async" : "", "defer" : "", "algo" : "", "crossorigin" : "" }
                ]
            }`
            &async=`false`
            &defer=`false`
            &algo=`sha384`
            &crossorigin=`anonymous`
            &lifetime=`604800`
        ]]
        [[+unpkg.com.link]]
        [[+unpkg.com.script]]
    

Script properties:

&packages
Required. JSON-object, containing information about packages, their versions and files. Package name is required, while all other properties are replaced by redirect defaults, if unspecified. A lot of packages have their default filename unassigned.
&async
Optional. Default is false. Async attribute value for all script subresources. Value is interpreted as a boolean. Can be specified for a script subresource.
&defer
Optional. Default is false. Defer attribute value for all script subresources. Value is interpreted as a boolean. Can be specified for a script subresource.
&algo
Optional. Default is sha384. Algorithm to use for subresource integrity hashing. Case insensitive. Possible values are: sha256, sha384, sha512. Can be specified for a subresource.
&crossorigin
Optional. Default is anonymous. Crossorigin attribute value for all subresources. Case insensitive. Possible values are: anonymous, use-credentials. Can be specified for a subresource.
&lifetime
Optional. Default is 604800. Subresource cache lifetime.

Placeholders:

[[+unpkg.com.link]]
Placeholder for all subresource link tags.
[[+unpkg.com.script]]
Placeholder for all subresource script tags.

Examples:

Most recent jQuery and prism.js ( async ) with daily updates:

    
        [[unpkg.com?
            &libraries=`{
                "script" : [
                    { "package" : "jquery", "file" : "dist/jquery.min.js" },
                    { "package" : "prismjs", "file" : "prism.js", "async" : "true" }
                ]
            }`
            &lifetime=`86400`
        ]]
    

Most recent Bootstrap with defer for all script subresources:

    
        [[unpkg.com?
            &libraries=`{
                "link" : [
                    { "package" : "bootstrap", "file" : "dist/css/bootstrap.min.css" }
                ],
                "script" : [
                    { "package" : "jquery", "file" : "dist/jquery.min.js" },
                    { "package" : "popper.js", "file" : "dist/umd/popper.min.js" },
                    { "package" : "bootstrap", "file" : "dist/js/bootstrap.min.js" }
                ]
            }`
            &defer=`true`
        ]]
    

Notes:

This extra is designed for easier package update management. It should not be used in case of strict project security requirements.