Skip to main content

Using CDN Assets(mainly JS and css) instead of downloading asset by your self.

Project description

This package help you to use CDN Assets instead of downloading js and css by your self.

Quick start

  1. Install this package:

    pip install cdn_assets

  2. Add “cdn-assets” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'cdn_assets',
    ]
  3. Using filter we provide like this:

    {% load cdn_assets %}
    
    {% cdn bootcss %}
        {% asset bootstrap 3.3.5 css bootstrap.min css %}
        {% asset jquery 2.2.1 jquery.min js %}
    {% endcdn %}
    
    
    This will output ::
    <script src="//cdn.bootcss.com/jquery/2.2.1/jquery.min.js"></script>
    <link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    
    Explaination ::
    {% cdn bootcss %}
        {% asset jquery 2.2.1 jquery.min js %}
    {% endcdn %}
    The last parameter for asset filter is js, It would generate <script>
    If the last parameter is css, then it would be <link rel='stylesheet'>
    '/'.join() jquery 2.2.1 jquery.min -> jquery/2.2.1/jquery.min
    adding the js it becomes jquery/2.2.1/jquery.min.js
    The host is bootcss, so the url would be //cdn.bootcss.com/jquery/2.2.1/jquery.min.js
  4. CDN Host list:

    HOST_MAPPINGS = {
        'bootcss':      'cdn.bootcss.com',
        'baidu':        'libs.baidu.com',
        'sinaapp':      'lib.sinaapp.com',
        'aspnetcdn':    'jax.aspnetcdn.com',
        'google':       'ajax.googleapis.com',
        'upai':         'upcdn.b0.upaiyun.com',
        'cdnjs':        'cdnjs.cloudflare.com',
        'staticfile':   'cdn.staticfile.org',
        '360':          'libs.useso.com'
    }

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdn_assets-0.2.3.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file cdn_assets-0.2.3.tar.gz.

File metadata

  • Download URL: cdn_assets-0.2.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cdn_assets-0.2.3.tar.gz
Algorithm Hash digest
SHA256 3ee76fc680eaf5aa9b88516924510b06253246420332ae8951e051b02e45d839
MD5 08e9bd3bd00941b4bf029c74f9902831
BLAKE2b-256 2fcfd303dbd0cc671fcb8fc18bf66858ca09b5697e38a6dbc424814c67f2e6e1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page