npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

infile-lazyload-split-loader

v1.0.0

Published

A Webpack loader for splitting and lazily loading functions directly from within JavaScript files.

Downloads

64

Readme

Infile-LazyLoad-Split-Loader

A Webpack loader for lazy loading functions marked with // @lazy-load

Infile-LazyLoad-Split-Loader is a Webpack loader designed to enhance your JavaScript projects by automatically splitting and lazily loading functions marked with a @lazy-load comment. This approach helps in reducing the initial load time of your applications by splitting off heavy functions into separate chunks that load only when needed.

Features

  • Lazy Loading: Automatically transforms and splits marked functions into separate chunks.
  • Easy Integration: Seamlessly integrates with your existing Webpack setup.
  • Configurable: Offers options to customize the lazy loading behavior.

Installation

Install the loader via npm:

npm install infile-lazyload-split-loader --save-dev

Or via yarn:

yarn add infile-lazyload-split-loader --dev

Usage

To use the Infile-LazyLoad-Split-Loader, add it to your Webpack configuration:

// webpack.config.js
    module.exports = {
    module: {
        rules: [
        {
            test: /\.js$/,
            use: [
            {
                loader: 'infile-lazyload-split-loader',
                options: {
                // Optional configuration settings
                }
            }
            ]
        }
        ]
    }
    };

In your JavaScript files, mark the functions you want to lazy load with the @lazy-load comment:

// myModule.js

    // @lazy-load
    export function heavyFunction() {
     // to be be split off into a separate chunk
    }

    // @lazy-load
    export const anotherHeavyFunction = () => {
     // to be be split off into a separate chunk
    }

in your main file, import the function as you would normally do for named exports. The loader will automatically split off the marked functions into separate chunks and load them only when needed. For example:

// main.js

    import { heavyFunction, anotherHeavyFunction } from './myModule.js';

    heavyFunction();
    anotherHeavyFunction();

Limitations

  • The loader currently only supports inline functions.
  • No function call from outside the function is allowed.

License

MIT