Coder Social home page Coder Social logo

Custom selector about instantclick HOT 5 CLOSED

pasine avatar pasine commented on September 24, 2024
Custom selector

from instantclick.

Comments (5)

pasine avatar pasine commented on September 24, 2024

I have tried to add this feature.
You can see it in my fork.
Since I had to add a new argument to handle the selecor, I prefered to pass everything as an object instead of comma separated paramters.
This would break the actual configuration of the library, that's why I didn't create a pull request.
I think passing parameters as

{mouseover: true, delay: 50, selector : '#foo a'}

will make things much readable, but this is a personal opinion.
With my changes, you can now select which link you want to be preloadable by passing a selector to the init function.

InstantClick.init({ selector : 'a.preload' }); 

from instantclick.

dieulot avatar dieulot commented on September 24, 2024

I’m thinking about adding the ability to add data-instant/data-no-instant to a non-link element. That would whitelist/blacklist all links in that element.

In your case, you’d enable whitelisting (InstantClick.init(true)) and then add a data-instant attribute to the element you’re currently using as your selector. That’d solve your problem, right?

from instantclick.

pasine avatar pasine commented on September 24, 2024

Can I ask you why do you prefer to use a data attribute instead of using a javascript selector? Is it for performance or for convenience?

from instantclick.

dieulot avatar dieulot commented on September 24, 2024

Convenience for the person new to InstantClick. Allowing two ways to do the same thing would duplicate one’s effort to learn how to set up InstantClick.

The only advantage I see from using selectors over data(-no)-instant on a parent attribute is that you can use classes if you prefer. Not worth the drawback of inhibited learning.

from instantclick.

dieulot avatar dieulot commented on September 24, 2024

Blacklisting/Whitelisting all links in one container has landed in 64876dc.

from instantclick.

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.