educational

JQuery: Direct Load or CDN?

One of the first questions that jQuery users need to ask is “should I host the core files on my own server, or rely on Google’s content delivery network (CDN) to host jQuery?”

While increased feature flexibility and control over source code integrity are cited as common reasons why hosting your own jQuery files makes sense, there are compelling reasons why letting Google handle the task makes sense — including the basic fact that no matter how good your hosting service is, it still likely pales in comparison to Google’s robust and exquisitely maintained CDN — and while bandwidth is much less expensive today than in the past, high volume sites could see significant savings by using these free host services, which perform as well and fast as (or better than) any premium offerings.

should I host the core files on my own server, or rely on Google’s content delivery network (CDN) to host jQuery?

Still, for some webmasters, the nagging feeling that all files should be self-hosted to ensure their contents and availability with the rest of the site’s files is hard to overcome.

For these users, we offer a way to have your cake and eat it too: relying on Google’s CDN to serve up the jQuery core, with a fallback to a selfhosted version “just in case.”

<?php
function loadjquery(){
$url = ?https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js?;
if(@fopen($url, ?r?)){echo ?<script type=\?text/javascript\? src=\?? . $url . ?\?></script>\n?;
} else {
echo ?<script type=\?text/javascript\? src=\?/js/jquery.js\?></script>\n?;
}
}
?>

Not only will this technique provide your website with a more efficient infrastructure while saving on bandwidth and other expenses, but it could dramatically speed up your site’s loading time, since visitors may already have downloaded the jQuery package from the Google CDN. Note that Microsoft and jQuery also provide CDN services, making for additional options, such as using the Google CDN as the primary source and Microsoft’s CDN as the fallback source — and then perhaps a tertiary fallback to a self-hosted copy.

However you choose to implement jQuery, combining free CDN delivery with a selfhosted backup copy will easily give you and your site’s users the best of both worlds.

Related:  

Copyright © 2025 Adnet Media. All Rights Reserved. XBIZ is a trademark of Adnet Media.
Reproduction in whole or in part in any form or medium without express written permission is prohibited.

More Articles

opinion

Eight Steps to Fast-Track AI Site Approval for Processing

Artificial intelligence is a hot topic these days. AI technology is speeding up the way we do business across all industries and offers numerous benefits, from automating processes to increasing efficiency and scalability.

Cathy Beardsley ·
opinion

How to Secure High-Risk Transactions With Network Tokenization

Ensuring the security of data as it moves through digital channels is the foundation of safe transactions, and crucial for your success. If your business can’t secure transactions, you’re exposed to myriad processing traumas.

Jonathan Corona ·
profile

WIA Profile: Reba Rocket

As chief operating officer and chief marketing officer of Takedown Piracy, long at the forefront of intellectual property protection in adult entertainment, Rocket is dedicated to safeguarding the livelihoods of content creators and producers while fostering a more ethical and sustainable industry.

Women In Adult ·
opinion

Protecting Content Ownership Rights When Using AI

In today’s digital age, content producers have more tools at their disposal than ever before. Among these tools, artificial intelligence (AI) content generation has emerged as a game changer, enabling creators to produce high-quality content quickly and efficiently.

Corey D. Silverstein ·
opinion

How Payment Orchestration Can Help Your Business

An emerging payment solution is making waves in the merchant world: the payment orchestration platform (POP). It’s quickly gaining traction as a powerful tool for managing online payments — but questions abound.

Cathy Beardsley ·
opinion

Fine-Tuning Refund and Cancellation Policies

For adult websites, managing refunds and cancellations isn’t just about customer service. It’s a crucial factor in maintaining compliance with the regulations of payment processors and payment networks such as Visa and Mastercard.

Jonathan Corona ·
profile

WIA Profile: Laurel Bencomo

Born in Cambridge, England but raised in Spain, Laurel Bencomo initially chose to study business at the University of Barcelona simply because it felt familiar — both of her parents are entrepreneurs. She went on to earn a master’s degree in sales and marketing management at the EADA Business School, while working in events for a group of restaurants in Barcelona.

Women In Adult ·
profile

Gregory Dorcel on Building Upon His Brand's Signature Legacy

“Whether reflected in the storyline or the cast or even the locations, the entertainment we deliver is based on fantasy,” he elaborates. “Our business is not, and never has been, reality. People who are buying our content aren’t expecting reality, or direct contact with stars like you can have with OnlyFans,” he says.

Jeff Dana ·
opinion

How to Turn Card Brand Compliance Into Effective Marketing

In the adult sector, compliance is often treated as a gauntlet of mandatory checkboxes. While it’s true that those boxes need to be ticked and regulations must be followed, sites that view compliance strictly as a chore risk missing out on a bigger opportunity.

Jonathan Corona ·
opinion

A Look at the Latest AI Tools for Online Safety

One of the defining challenges for adult businesses is helping to combat the proliferation of illegal or nonconsensual content, as well as preventing minors from accessing inappropriate or harmful material — all the more so because companies or sites unable or unwilling to do so may expose themselves to significant penalties and put their users at risk.

Gavin Worrall ·
Show More