Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

osherdo's avatar

Include js file after the jquery library

Hello everyone.

I need to include external js file right after the jquery file in a page. The problem is if I try to include it in in the page - it first loads the external js file and then the jquery library. By this i cannot take advantage of Jquery.

How can I load the js file right after jquery (which is loaded in the master page) and do it right in the page I need - and not in the master page?

Thanks.

0 likes
3 replies
tykus's avatar

You could have a @section('scripts') included on the layout after the jQuery script and in your view include whatever script you need

tykus's avatar
tykus
Best Answer
Level 104
// in your layout
<script src="path/to/jquery.js">
@yield('scripts')

// in your view
@section('scripts')
  <script src="path/to/script">
@stop
4 likes

Please or to participate in this conversation.