Coder Social home page Coder Social logo

Require CSS in the path about require-css HOT 4 OPEN

 avatar commented on August 12, 2024
Require CSS in the path

from require-css.

Comments (4)

 avatar commented on August 12, 2024 1

Absolutely that works - but my question is - can it be shortened and made less verbose? I want datatables.net-bs to include the DataTables Bootstrap integration for the CSS and the JS with a since call, since one without the other is more or less redundant.

As I noted in my original post, this is absolutely possible already, but I'm looking to see if @guybedford knows if there is a cleaner approach.

from require-css.

ffflabs avatar ffflabs commented on August 12, 2024

I would start by trying with local copies, for example using bower to forget about manually updating the dependencies. Since there isn't a way to know for sure when a CSS stylesheet is done loading, you're asking too much.

Second, you might want to look at normalize.js to see how the plugin deals with protocol relative urls and fallback paths.

Third, the deps property shouldn't be parallel to paths. At least the way I config my apps, deps is a property of each module under the shims config.

from require-css.

 avatar commented on August 12, 2024

Thanks for the reply.

Since there isn't a way to know for sure when a CSS stylesheet is done loading

My understanding of what this plug-in for requirejs does is exactly that - from the readme: "Allows the construction of scripts that can require CSS"

Second, you might want to look at normalize.js to see how the plugin deals with protocol relative urls and fallback paths.

Thank you I will. I'm not sure how that will help with using require-css! in the paths, but it might point to how a plug-in can be used to operate on the path.

Third, the deps property shouldn't be parallel to paths

The requirejs docs state that the config.deps option can be used to require a module immediately, which is what I used it for above. It could equally be in the require line, but I just put it in the deps config for simplicity.

from require-css.

ffflabs avatar ffflabs commented on August 12, 2024

This one worked for me

requirejs.config({

    paths: {
        "require-css": "//cdnjs.cloudflare.com/ajax/libs/require-css/0.1.8/css.min",
        "jquery": "//code.jquery.com/jquery-2.1.4.min",
        "bootstrap": "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min",
        "datatables.net": "//nightly.datatables.net/js/jquery.dataTables.min",
        "datatables.net-bs-js": "//nightly.datatables.net/js/dataTables.bootstrap.min",
        "datatables.net-bs-style": "//nightly.datatables.net/css/dataTables.bootstrap.min"
    }
});

define([
    "jquery",
    "datatables.net",
    "datatables.net-bs-js",
    "require-css!bootstrap",
    "require-css!datatables.net-bs-style"

], function (jQuery) {

    jQuery(document).ready(function () {
        jQuery('#myTable').DataTable();
    });

});

from require-css.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.