adunblock/server-tag-laravel

A Laravel package to fetch and render scripts from a remote URL with caching support.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

pkg:composer/adunblock/server-tag-laravel

dev-master 2026-01-20 16:35 UTC

This package is auto-updated.

Last update: 2026-01-20 16:35:18 UTC


README

A Laravel package to fetch and render scripts from a remote URL with caching support.

Installation

Install the package via Composer:

composer require adunblock/server-tag-laravel

The package will be automatically registered via Laravel's package auto-discovery feature.

Usage

In your Blade template, you can now use the server_tag function:

<!DOCTYPE html>
<html>
<head>
  <title>My Page</title>
  {!! server_tag('https://your-remote-url.com/scripts') !!}
</head>
<body>
  <h1>My Page</h1>
</body>
</html>

Custom Rendering

You can provide a custom closure to the render_script argument to render the script tags in a different way:

<!DOCTYPE html>
<html>
<head>
  <title>My Page</title>
  {!!
    server_tag('https://your-remote-url.com/scripts', 300, function($scripts) {
      $scriptTags = array_map(function ($src) {
        return "<script src=\"{$src}\" defer></script>";
      }, $scripts);
      return implode("\n", $scriptTags);
    })
  !!}
</head>
<body>
  <h1>My Page</h1>
</body>
</html>