
Dynamic script & style (and more) injection for Hexo
With the recent updates in Hexo, the importance of effective content injection has taken a new turn. While the hexo-inject plugin has been deprecated, Hexo itself now offers built-in injector support since version 5.0.0. This change makes it easier for developers to seamlessly integrate custom code into rendered HTML, simplifying the development process for themes and plugins.
The built-in injector provides various ways to inject scripts, styles, and content at specific points in the HTML document. This ensures that developers can continue to enhance their sites with dynamic content without relying on external plugins, unifying their workflow within the Hexo ecosystem.
Multiple Injection Points: Utilize four distinct injection points—head_begin, head_end, body_begin, and body_end—for precise control over where your content is placed within the HTML structure.
Simple Injection Helpers: Access quick helper functions such as tag, script, style, and link for straightforward and efficient content injection with minimal setup.
Dynamic Content Handling: The injection system accepts strings, Promises, or functions for content, allowing for dynamic content generation tailored to the current HTML page.
File Injection Support: Leverage the require helper to inject external files, with options for inline or served references, enhancing flexibility with how assets are managed.
Custom Loader Capabilities: Implement your own loaders for specific file formats, enabling greater customization beyond the default support for .js and .css files.
Condition-based Injection: Use the shouldInject option to control whether certain content should be injected based on the current page’s HTML, offering conditional rendering capabilities.
NPM Integration: Easily install the built-in injector via npm, simplifying the setup process for new and existing Hexo projects.
Through these features, Hexo's built-in injector provides a powerful alternative for developers looking to enhance the functionality and customization of their websites.

Hexo is a static site generator built with Node.js that enables developers to create fast and efficient websites using Markdown, EJS, and Stylus. It offers features such as server-side rendering, plugin support, and easy deployment to hosting services like GitHub Pages and Netlify.
ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.