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 🙏

© 2025 – Pkg Stats / Ryan Hefner

laravel-route-scripts

v1.0.8

Published

This package helps to execute Javascript with all the power of laravel mix webpack in your Laravel Names Routes.

Readme

Laravel Route Scripts

This package helps to execute Javascript with all the power of laravel mix webpack in your Laravel Named Routes.

Sometimes you don't have a running SPA in your Laravel app but you want to run modern javascript with laravel mix workflow on specific pages to ad some vuejs interactions. If that's the case this package can help you.

Installation

  1. Install as dependency:
npm instal laravel-route-scripts --save-dev

or

 yarn add laravel-route-scripts --dev

Usage

  1. In your main view layout blade file you must set to any element the attribute: data-laravel-route-name="{{ Route::currentRouteName() }}". You can get all your routes name by running php artisan route:list.

  2. Then just need to create a javascrtipt file on any location inside resources/js and import it in your mail js file.

  3. Import in your new file the library. Example: import LR from 'laravel-route-scripts'.

  4. In the new file create a new instance new LR('laravel.name.route').onInit(() => { console.log('js code here') }), if you need to run the same code on several routes you can also use an array of route names in the constructor function.

  5. You can chain this methods: onInit or docReady with a callback with your code.

How it works

php artisan route list - Run this command to locate your target route name in this example we use: contributors.photos.create

data-laravel-route-name="{{ Route::currentRouteName() }}" will create this attribute.

New imported file example.

import LR from 'laravel-route-scripts';
import Vue from 'vue'

// pass the route name or array of route names ['contributors.photos.create', 'contributors.photos.show']
new LR('contributors.photos.create')
  .onInit((lr) => {

    console.log('This run immediately javascript executes')

    // you can start vue here liks `new Vue(options)` or use lr initVue helper
    // with the lr reference you can access to the current instance also
    lr.initVue(Vue, {
      el: '#frontend-vue',
      data () {
        return {
          title: 'title'
        }
      },
    })
    
    // helper function to check if you are in specific route, handy when you are running in multiple routes
    console.log(lr.isRoute('contributors.photos.create'))

  }).docReady((lr) => {
    console.log('This runs when the DOM is ready')
    
    console.log(lr.$vi); // access the created vuejs instance
  })

Available API:

NOTES:

  1. onInit and docReady have access to receive an parameter that reference the instance itself.

License

MIT