惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 聂微东
宝玉的分享
宝玉的分享
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
博客园 - 【当耐特】
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
博客园 - 司徒正美
博客园 - Franky
爱范儿
爱范儿
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
量子位
博客园 - 叶小钗
博客园_首页
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

Pressable

Pressable Achieves Secure Hosting Alliance Certification | Pressable How Pressable MCP Is Changing The Game For WordPress Agencies: A Live Breakdown With Matt Medeiros And Phill Clapham | Pressable April Product Update: Navigation, Organization, And Efficiency | Pressable White-Label WordPress Hosting For Profitable Agencies | Pressable A Guide To Client Onboarding For WordPress Agencies| Pressable WordPress Plugin Management For Scalable Agencies | Pressable WordPress Maintenance Contracts For Agencies: A Complete Guide | Pressable 6 Essential SOPs For WordPress Agencies | Pressable Pressable MCP: Control Your WordPress Hosting With AI. | Pressable WordPress Hosting Cost: Pricing Tiers And What To Expect | Pressable WordPress Performance Budgets: Setting And Monitoring Goals | Pressable WordPress Automation With No Code Automation Tools | Pressable Implement Single Sign-On (SSO) In WordPress | Pressable How To Build A Real Estate Site On WordPress | Pressable Headless WordPress Showdown: Next.js Vs Gatsby | Pressable How To Automate White-Label WordPress Hosting With WHMCS | Pressable Developer Toolkit Update: Automation & UI Enhancements | Pressable How To Build A DXP Platform With WordPress How To Boost WordPress Agency Client Retention: 4 Strategies White Label WordPress Admin For Agency Clients Performance Testing For WordPress Agency Client Sites Performance Testing For WordPress: A Framework For Agency Client Sites How To Upload A Video To WordPress | Pressable How To Mitigate The Impact Of AI Scraper Bots On WordPress Sites WooCommerce ERP Integration: Automate Your Back Office WordPress Personalization: How To Display Tailored Content To Visitors | Pressable WooCommerce Conversion Rate Optimization: A Data-Driven Approach How To Price Your Online Course: WordPress Monetization Guide 7 Ecommerce KPIs You Should Be Measuring | Pressable WooCommerce Vs. BigCommerce: Which Is Best For Your Business Needs? | Pressable WooCommerce Performance Troubleshooting: Diagnosing Speed Issues Step-by-Step | Pressable
How To Optimize JavaScript Pages For SEO | Pressable
Kevin MacGillivray · 2021-12-09 · via Pressable

Two people collaborate on coding at a computer, surrounded by a modern office setting.

Ask Your Favorite AI

Copy the link to a markdown format of this article for ChatGPT, Claude, Gemini, or your favorite AI.

Hypertext markup language (HTML) isn’t the only type of code used to develop websites. While all websites contain HTML, many of them contain JavaScript as well. A report by W3Techs found that at least some JavaScript code powers over 97 percent of websites. If you use this programming language for web development purposes, though, you’ll need to optimize your website’s JavaScript pages for search engines.

The Basics of JavaScript

JavaScript is a fluid, client-side programming language that consists of text-based scripts. These scripts allow for interactions between visitors and pages. Visitors can essentially change the content displayed on JavaScript pages.

As a client-side programming language, JavaScript runs in web browsers. Visitors may click or scroll to an interactive element on a page, at which point their web browsers will execute the JavaScript. Visitors’ web browsers will then change the page’s content.

The SEO Hurdles of JavaScript

While helpful in developing interactive pages, JavaScript can pose issues for search engine optimization (SEO). Search engines must render pages before they can rank them. Rendering is a crawling-related process in which search engines attempt to view pages from a visitor’s perspective. With JavaScript, search engines may render pages incorrectly, resulting in lower search rankings.

Pages with only HTML and Cascading Style Sheets (CSS) are easy for search engines to render. Search engines will read the HTML to identify the pages’ content, and they’ll analyze the CSS to determine how the content is presented. If a page contains JavaScript, on the other hand, search engines may overlook some of its content.

Using too much JavaScript on a page – or failing to optimize its JavaScrip – may slow it down. The more JavaScript a page has, the harder web browsers will have to work to load it. Slow-loading pages, of course, often rank lower than fast-loading pages.

Using HTML for links will improve the SEO of your JavaScript pages. Links can be defined with different types of code. You can define them with HTML by using the anchor element, or you can define links with JavaScript by using the onclick event.

The problem with JavaScript-defined links is that search engines may not see them. Google, for instance, says it only crawls HTML-defined links. You can use JavaScript to display links, but you should use HTML to define the links rather than JavaScript. Links featuring the onclick JavaScript event may go unnoticed by Google.

Make JavaScript Files Accessible to Search Engines

You should make all of your site’s JavaScript files search engine accessible. To correctly render a JavaScript page, search engines must be able to access all of its JavaScript code. If the code is placed in an external file and you block search engines from accessing it, they won’t be able to render the page.

Of course, JavaScript doesn’t have to be placed in an external file. Like with CSS, it can be embedded directly in pages. Known as inline JavaScript, it eliminates the need for a separate and external file. As long as search engines can access the page, they’ll be able to access its JavaScript code. However, if you use external JavaScript files, you should use your website’s robots directives to ensure search engines can access them.

Don’t Forget Title and Description SEO Meta Tags

JavaScript pages require many of the same SEO meta tags as HTML and CSS pages. Among the most important SEO meta tags are the title and description. The title SEO meta tag is displayed in web browsers, and search engines typically use it to generate titles for indexed pages. While the description SEO meta tag isn’t displayed in web browsers, search engines may use it to create text snippets or descriptions for indexed pages.

There’s nothing wrong with using JavaScript to define title and description SEO meta tags. According to Google, JavaScript can even be used to change both of these SEO meta tags. The bottom line is that all pages should have a title and description meta SEO meta, including those developed mostly in JavaScript.

Complement Infinite Scrolling With Pagination

A common use for JavaScript is to create infinite scrolling. Also known as endless scrolling, it’s an interactive feature that dynamically loads new content as visitors scroll down the page. Infinite scrolling is commonly used on blog feed pages and visitor comment pages. Rather than creating multiple pages of blog feeds or visitor comments, you can create a single page with infinite scrolling.

By itself, infinite scrolling is horrible for SEO. Search engines don’t scroll when rendering pages. Therefore, they’ll only see the content that doesn’t require visitors to scroll down. Any content that’s hidden with infinite scrolling won’t affect the page’s search rankings.

You can use pagination in conjunction with infinite scrolling for improved SEO. Pagination is a navigation process that involves separating a single long-form page into multiple short-form pages. Infinite scrolling pages are long-form. You can include pagination links to other, short-form pages that feature the hidden content on these pages.

Optimize With Minification

Minification can improve your JavaScript pages’ SEO. Minifying JavaScript creates cleaner and more concise scripts by stripping away pointless characters. Letters, spaces, and special characters that don’t serve any purpose will be removed. With fewer total characters, the scripts will load faster. They’ll also be easier for search engines to process.

You can minify JavaScript manually by going through each script and removing unnecessary characters. Alternatively, you can minify JavaScript automatically by using a tool. Fast Velocity Minify is a WordPress plugin that offers minification for JavaScript as well as CSS. It will minify both types of code on your website, assuming your site runs WordPress. And there’s a JavaScript minification tool at jscompress.com that works for all website platforms.

Some Final Thoughts

JavaScript pages can still rank on the first page, but only if you optimize them. Search engines may not render them correctly otherwise. JavaScript SEO consists of using HTML for links, making JavaScript files search engine-accessible, including SEO meta tags on pages, using pagination with infinite scrolling and minification. For more SEO tips, take a look at the following blog articles:

Can iFrames Harm Your WordPress Website’s SEO?

How to Use Keyword Mapping to Improve SEO

Website Hosting and SEO: What’s the Connection (and Why It’s Important)

Pro Tips for Getting the Most Out of Yoast

How to Create Custom Meta Tags for a WordPress Website

Kevin MacGillivray

Kevin MacGillivray is the Chief Marketing Officer at Pressable, where he’s focused on helping more creators build fast, secure, and successful WordPress sites. He’s driven to grow Pressable’s impact and make it the go-to choice for more businesses. Kevin enjoys making technology feel simple, useful, and inspiring through clear storytelling, creative experiments, and building new ways for the community to connect and thrive. Kevin lives in Victoria, British Columbia, where you’ll often find him swimming in the ocean, exploring local trails with his dog, Minerva, or embracing the West Coast’s vibrant lifestyle and easy rhythm.