PHPackages                             adunblock/server-tag-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. adunblock/server-tag-laravel

ActiveLibrary[Templating &amp; Views](/categories/templating)

adunblock/server-tag-laravel
============================

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

v1.1.0(2mo ago)03ISCPHPPHP &gt;=7.4

Since Jan 20Pushed 2mo agoCompare

[ Source](https://github.com/adunblock/adunblock-server-tag-laravel)[ Packagist](https://packagist.org/packages/adunblock/server-tag-laravel)[ Docs](https://github.com/adunblock/adunblock-server-tag)[ RSS](/packages/adunblock-server-tag-laravel/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (3)Used By (0)

Server Tag Laravel Package
==========================

[](#server-tag-laravel-package)

A Laravel package to fetch and render scripts from a remote URL with caching support. Perfect for server-side script loading and integration with third-party services.

Features
--------

[](#features)

- Server-side script fetching from remote URLs
- Built-in caching support to reduce external requests
- Customizable rendering with closures
- Automatic Laravel service provider registration
- Works seamlessly with Blade templates
- Support for Laravel 8, 9, 10, 11, and 12

Requirements
------------

[](#requirements)

- PHP 7.4 or higher
- Laravel 8.x, 9.x, 10.x, 11.x, or 12.x

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require adunblock/server-tag-laravel:^1.0
```

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

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

In your Blade template, use the `server_tag()` helper function to fetch and render scripts from a remote URL:

```
DOCTYPE html>

  My Page
  {!! server_tag('https://your-remote-url.com/scripts') !!}

  My Page

```

### With Caching

[](#with-caching)

Specify a cache duration (in seconds) as the second parameter:

```
{!! server_tag('https://your-remote-url.com/scripts', 300) !!}
```

This will cache the fetched scripts for 5 minutes (300 seconds), reducing external requests.

### Custom Script Attributes

[](#custom-script-attributes)

Pass an associative array as the fourth parameter to render extra attributes (including `data-*`) on every generated `` tag:

```
{!!
  server_tag('https://your-remote-url.com/scripts', 300, null, [
    'data-code' => 'abc123',
    'data-source' => 'server-tag',
    'defer' => true,
  ])
!!}
```

Rendering rules:

- `true` → bare attribute (e.g. `defer`)
- `false` / `null` → omitted
- any other value → `key="value"` (HTML-escaped)

By default every rendered script includes `async`. Set `'async' => false` to disable it.

### Custom Rendering

[](#custom-rendering)

You can provide a custom closure as the third parameter to control how script tags are rendered:

```
{!!
  server_tag('https://your-remote-url.com/scripts', 300, function($scripts) {
    $scriptTags = array_map(function ($src) {
      return "";
    }, $scripts);
    return implode("\n", $scriptTags);
  })
!!}
```

### Function Signature

[](#function-signature)

```
server_tag(string $url, int $cache_seconds = 300, ?callable $render_script = null, ?array $script_attributes = null): string
```

**Parameters:**

- `$url` (string): The remote URL to fetch scripts from
- `$cache_seconds` (int, optional): Cache duration in seconds. Default is 300
- `$render_script` (callable, optional): Custom rendering function. Receives an array of script URLs and returns an HTML string
- `$script_attributes` (array, optional): Associative array of attributes to render on every `` tag (e.g. `['data-code' => 'abc']`). Defaults to `['async' => true]`

How It Works
------------

[](#how-it-works)

1. The helper fetches content from the specified remote URL using Laravel's HTTP client
2. If caching is enabled, the response is stored in Laravel's cache for the specified duration
3. The fetched scripts are rendered as `` tags (or using your custom renderer)
4. The HTML is returned and can be used directly in your Blade templates

License
-------

[](#license)

ISC

Support
-------

[](#support)

- Issues: [GitHub Issues](https://github.com/adunblock/adunblock-server-tag/issues)
- Homepage:

Author
------

[](#author)

AdUnblock -

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance85

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~87 days

Total

2

Last Release

78d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/204576902?v=4)[Bill](/maintainers/billadunblock)[@billadunblock](https://github.com/billadunblock)

---

Top Contributors

[![billadunblock](https://avatars.githubusercontent.com/u/204576902?v=4)](https://github.com/billadunblock "billadunblock (6 commits)")

---

Tags

phplaravelhelperbladeserver-tagscript-loadingremote-scripts

### Embed Badge

![Health badge](/badges/adunblock-server-tag-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/adunblock-server-tag-laravel/health.svg)](https://phpackages.com/packages/adunblock-server-tag-laravel)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.5k55.4M8.5k](/packages/larastan-larastan)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.9k3](/packages/defstudio-telegraph)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
