Hotlink resources like JavaScript files directly from GitHub [duplicate]

Active3 hr before
Viewed126 times

7 Answers


I asked a question about including resources from GitHub and the answer was to use the raw link:,And yes, @Lix is correct. The files are not being served from Github but from combinatronics., GitLab launches Collective on Stack Overflow ,the script is out there at (it may take about 10 minutes to update)

But thanks to we can include GH scripts. The only change is from that becomes

<script type="text/javascript" src=""></script>
load more v

We added the X-Content-Type-Options: nosniff header to our raw URL responses way back in 2011 as a first step in combating hotlinking. This has the effect of forcing the browser to treat content in accordance with the Content-Type header. That means that when we set Content-Type: text/plain for raw views of files, the browser will refuse to treat that file as JavaScript or CSS.,some options for delivering content with with proper Content-Type headers. ,I don't recommend you use the way in any official product, but as a test or write some practice scripts, handy, can save a lot of duplication of code, This does not send the correct headers (should be application/json, is text/plain). – Sumit May 21 '19 at 13:20

I would like something like this:

<script src="[username]/[repository]/blob/master/public/[fileName].js"></script>
load more v

First, you have to select where your code is stored. In this scenario, select Remote git hosting like GitHub or BitBucket.,A target directory for publishing Git files on your website. By default, the /httpdocs directory is used. You can change it to another existing directory by clicking the directory name., A target directory for publishing Git files on your website. By default, the /httpdocs directory is used. You can change it to another existing directory by clicking the directory name. ,Click OK. Plesk will try to connect to the remote repository and clone it.

A target directory for publishing Git files on your website. By default, the /httpdocs directory is used. You can change it to another existing directory by clicking the directory name.

load more v

Please do not hotlink directly to the files hosted on Download a local copy instead.,Many JavaScript libraries use $ as a function or variable name, just as Tire does. If you like to use another JavaScript library alongside Tire, we can return control back of $ to the other library with $.noConflict.,Fixes for older browsers increase the file size and we don't want that. So if you like a library to support Internet Explorer 6 or 7, Tire isn't for you. ,Tire is a lightweight JavaScript library for modern browsers. The syntax is inspired from jQuery. It's modular so you can extend it however you like, also replace our features with your own.

The function will take two parameters, the first is a selector and the second is the context (or attribute object) where you are searching for the DOM node. If no context is given the context will be document. If a tire collection is given it will just return the given collection.

$('#foo') // returns the element with the id foo

$('.bar') // returns all elements with the class name bar.

$('p') // returns all elements with the tag name p.

// More advanced selectors via document.querySelectorAll.

$('input[type=text]') // returns all input elements with the type text.

$('a, div') // returns all a and div elements;

$('ul li') // returns all li elements that are inside an ul tag.

$('ol > li') // the same as above but for ol tag.

$('<a />', { href: '#', title: 'a' }); // Add attributes to the tag (1.1.1+).
load more v

I have a dataframe of transactions. Each row represents a transaction of two item (think of it like a transaction of 2 event tickets or something). I want to duplicate each row based on the quantity sold. ,I created a new DataFrame by using a nested list comprehension structure. ,So in the case above, each row will transform into two duplicate rows. If the 'quantity' column was 3, then that row would transform into three duplicate rows.,How about this approach. I changed your data slightly to call out a sale of 4 tickets.

Here's example code:

# dictionary of transactions

d = {
   '1': ['20', 'NYC', '2'],
   '2': ['30', 'NYC', '2'],
   '3': ['5', 'NYC', '2'],
   '4': ['300', 'LA', '2'],
   '5': ['30', 'LA', '2'],
   '6': ['100', 'LA', '2']

columns = ['Price', 'City', 'Quantity']

# create dataframe and rename columns

df = pd.DataFrame.from_dict(
   data = d, orient = 'index'
df.columns = columns

This produces a dataframe that looks like this

Price City Quantity
20 NYC 2
30 NYC 2
5 NYC 2
300 LA 2
30 LA 2
100 LA 2
load more v

If you are using KeyCDN, simply click into Zonereferrers and add the rules. Crawlers will still be able to access and index your images.,When I checked, I found hotlink protection is not enabled on Kinsta. I’m interested to know why?,Hotlinking in a lot of cases is actually illegal. Why? Because many of the photos you see around the web have licensing restrictions attached to them. Here are a couple of common image restrictions on licensing from popular stock photo sites:,If you are running on NGINX, all you need to do is open your config file and add the following:

Simply add the following code below:

   "Version": "2008-10-17",
   "Id": "preventHotLinking",
   "Statement": [{
      "Sid": "1",
      "Effect": "Allow",
      "Principal": {
         "AWS": "*"
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::my-brand-new-bucket/*",
      "Condition": {
         "StringLike": {
            "aws:Referer": [
load more v

In the WP Rocket file optimization settings, minify CSS/JS should be enabled, but combine CSS/JS should only be enabled for websites with small CSS/JS file sizes. Optimize CSS delivery can cause layout shifts (you will need to test this) and everything else should be enabled including remove unused CSS, load JavaScript deferred, and delay JavaScript execution. You should ideally test each setting individually while measuring results in Lighthouse or GTmetrix.,Exclude CSS/JS Files – if a minification breaks your website layout, view your source code, locate the problematic file, and add it. See WP Rocket’s post on resolving minification issues.,Disabling Optimize CSS Delivery or setting a fallback critical CSS can fix CLS (cumulative layout shift) issues when using WP Rocket.,Enable Optimize CSS Delivery and Load JavaScript Deferred in WP Rocket's file optimization settings. If that doesn't work, try the Autoptimize or Async JavaScript plugin.

Delay JavaScript Execution – delays loading JavaScript until user interaction (i.e. scrolling or touching the screen on mobile). This feature alone reduced my blog’s load time by about 3s by delaying wpDiscuz comments and Gravatars. Here is the list of scripts automatically excluded by WP Rocket, but you may be able to delay other files (i.e. third-party code in your Lighthouse report). If you do this with ads or tracking scripts, make sure revenue/analytics aren’t affected. Note that WP Rocket removed Facebook Pixel from the “add-ons” tab and added here instead. If you want to add additional JavaScript files to delay, you would need to use a separate plugin like Flying Scripts or Perfmatters since WP Rocket no longer lets you add JavaScript manually.

cookie - law - info / p / platform.js
      /busting/facebook - tracking /
      /sdk.js#xfbml / includes / widgets / feedback - company - widget.min.js font - awesome ft.sdk.min.js adsbygoogle.js google - / analytics.js ga(' 
         ga(' /
            gtag / js gtag(
               /gtm.js /
               gtm -
      / translate_a / element.js / c / hotjar -
      / leadbars / current / embed.js / li.lms - analytics / insight.min.js / tracking.js LiveChatWidget olark
               pinit.js pixel - caffeine / build / frontend.js shareaholic ShopifyBuy sharethis simple - share - buttons - adder / loader.js Tawk_API / bootstrap - / uwt.js twq(
         / widgets.js wpdiscuz
load more v

Other "duplicate-files" queries related to "Hotlink resources like JavaScript files directly from GitHub [duplicate]"