Hi everyone, i'm new to laravel and i really hate js and i would like to clean my laravel app form any JS+Tailwind code or dependencies. Your help is appreciated
Laravel does not require JavaScript or Tailwind to work. They are included by default in recent versions for convenience. If you’re new to Laravel, you can also simply ignore JS entirely and use plain CSS without removing anything. If you are sure you want a strict no JS/Node setup, especially early in the project, you can do the following:
Just be aware that this setup diverges from Laravel’s defaults, so many tutorials and starter kits assume Vite and Tailwind are present. It's much easier to implement these changes before any project development, rather than after.
- Delete package.json and package-lock.json
- Delete vite.config.js
- Delete the resources/js and resources/css folders (if you plan to manage assets manually)
- Delete the node_modules folder
- Replace @vite within Blade templates: @vite(['resources/css/app.css', 'resources/js/app.js']) with <link rel="stylesheet" href="{{ asset('css/style.css') }}">
- Create blank index.blade.php or manually remove Tailwind classes from your preexisting .blade.php files
Just be aware that this setup diverges from Laravel’s defaults, so many tutorials and starter kits assume Vite and Tailwind are present. It's much easier to implement these changes before any project development, rather than after.
why avoid nodejs?,if no js not involved in the frontend then why does it matter?
You're right, the backend language doesn't technically matter, I'm simply answering what the OP asked, which was to achieve a completely JS free environment, unless I read their question wrong.
Also, for some developers, avoiding Node/NPM is about reducing complexity. If you don't need or want JS on the frontend, there's no reason to manage a node_modules folder or a Vite build step. It keeps the deployment PHP native and much easier to maintain long term.
If you want to avoid all third party bloat, another option is to build your own basic MVC framework with PHP. That gives you total transparency over the codebase, provided you're comfortable handling the core logic yourself. Obviously this is not recommended for beginners learning the basics of PHP or Laravel.
Also, for some developers, avoiding Node/NPM is about reducing complexity. If you don't need or want JS on the frontend, there's no reason to manage a node_modules folder or a Vite build step. It keeps the deployment PHP native and much easier to maintain long term.
If you want to avoid all third party bloat, another option is to build your own basic MVC framework with PHP. That gives you total transparency over the codebase, provided you're comfortable handling the core logic yourself. Obviously this is not recommended for beginners learning the basics of PHP or Laravel.
Thanks 0xyz i really appreciate your help, I thought it was more complicated than that. there is a smallish problem that Laravel uses tw for the pagination and I'm not using any css framework
Whoops, that's right. Sorry, I haven't used Laravel in quite some time. It's an easy fix though.
Open app/Providers/AppServiceProvider.php and update the boot method. This forces Laravel to stop using Tailwind's SVGs and utility classes:
By default, the step above still includes some Bootstrap specific CSS classes. To make it truly raw HTML, run this command:
Open app/Providers/AppServiceProvider.php and update the boot method. This forces Laravel to stop using Tailwind's SVGs and utility classes:
use Illuminate\Pagination\Paginator;
public function boot(): void
{
// this switches the default structure to standard <ul> and <li> tags
Paginator::useBootstrapFour();
}Even if you aren't using Bootstrap, this is the quickest way to get "normal" HTML that you can style with your own CSS.By default, the step above still includes some Bootstrap specific CSS classes. To make it truly raw HTML, run this command:
php artisan vendor:publish --tag=laravel-paginationNow, go to resources/views/vendor/pagination/bootstrap-4.blade.php. You can delete all the class="..." and aria label attributes. This leaves you with a 100% clean HTML structure that you can style with your own minimal CSS.Thanks again champ, i really appreciate your help 💯
thanks for answering,and yeah vite only needed when there is a frontend framework being used.
#1 problem is the transitive dependencies. Any sufficiently complex NodeJS program will have a dependency tree containing thousands of packages, any one of which can be compromised, leading to a compromise of your site or dev environment. This happens all the time.