Git Product home page Git Product logo

tachyon's People

Contributors

n3rdium avatar weebney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tachyon's Issues

Remove var usage

the mini version declares one of the variables using var - this is discouraged for many reasons, for example leakage of variables to global object when running in script mode (not module mode)

Google Tag Manager Invalid HTML, CSS or JavaScript.

Firstly, thanks a lot!

Copied the snippet to a new tag in Google Tag Manager.

<script src="https://unpkg.com/[email protected]/tachyon.min.js" integrity="sha384-4iJteL1FYnj4Ju83AJvNthpx5gZ1QaXCamXhY3lxhAjTNXUN+NXq5LQV/fXOSRme" type="module" crossorigin defer />

Seems to be the integrity parameter. Any suggestions?

Wrap script in IIFE

Should be rather easy to support scripts as well as modules and might be relevant for users (just make sure to wrap entire code in new scope to not leak variables to global scope)

(function(){
<tachyon-code>
}())

Combining Whitelist & Same-Origin

Hi!

Thank you very much for your script, I like the way you designed your library. It's really simple to understand, and it seems to do the job well, at least from my first tests! ๐Ÿค—

I just want you to know another use case that I think might be useful: combining data-tachyon-same-origin and data-tachyon-whitelist. This would allow the user to preload their website links and other links that a developer has marked in the allow list. For example, to preload links from:

Rest assured that I do not want you to implement this use case if you think it's not worth it for a lot of users. ๐Ÿ˜… I had already planned to use a slightly modified version of your script for my peculiar use case. ๐Ÿ˜‰

Thanks again!

~ Benjamin

  if ((node.tagName === 'A' && node.href) && (('tachyon' in node.dataset === whitelistEnabled) || (!sameOriginOnly || node.origin === window.location.origin))) {
    ['mouseover', 'mouseout', 'touchstart', 'touchend'].forEach((eventName) => node.addEventListener(eventName, toggleLinkTag, { passive: true }));
  }

Unhandled exception on text nodes

  1. Visit https://fasterthanlight.net/
  2. Open devtools and run document.body.append('x')
  3. The MObserver will catch the new text node and will try to execute "tachyon" in t.dataset but will fail because dataset is undefined for text nodes and in throws when right-hand is undefined

Cannot use 'in' operator

Hello, I added a script to the page, but it does not work, it gives errors in the console:
Uncaught TypeError: Cannot use 'in' operator to search for 'tachyon' in undefined
at t (tachyon.min.js:1:380)
at NodeList.forEach ()
at tachyon.min.js:1:619
at Array.forEach ()
at MutationObserver.observe.childList (tachyon.min.js:1:595)

What could be the problem? Thank you

Code golf

Replacing

if (!whitelistEnabled && !onList) {
addListenersToElement();
} else if (whitelistEnabled && onList) {
addListenersToElement();
}

With

 if (whitelistEnabled == onList) { 
   addListenersToElement(); 
 }

Will reduce the minifyed size by a whopping 10 bytes* ๐Ÿ˜„

* I haven't actually tried it to make sure ๐Ÿ˜…

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.