PHPackages                             craftsnippets/javascript-helpers - 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. craftsnippets/javascript-helpers

ActiveCraft-plugin[Templating &amp; Views](/categories/templating)

craftsnippets/javascript-helpers
================================

Twig tools for working with Javascript in templates

3.0.0(1y ago)11.3kMITPHP

Since Oct 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/craft-snippets/craft-javascript-helpers)[ Packagist](https://packagist.org/packages/craftsnippets/javascript-helpers)[ RSS](/packages/craftsnippets-javascript-helpers/feed)WikiDiscussions craft5 Synced 3w ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (0)

Javascript helpers plugin for Craft CMS 5.x
===========================================

[](#javascript-helpers-plugin-for-craft-cms-5x)

This plugin allows you to output all static translation messages into Javascript object and to easily transfer any Twig variables into Javascript.

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

[](#requirements)

This plugin requires Craft CMS 5.0.0 or later.

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

[](#installation)

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

    ```
     cd /path/to/project

    ```
2. Then tell Composer to load the plugin:

    ```
     composer require craftsnippets/javascript-helpers

    ```
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Javascript helpers.

Javascript helpers Overview
---------------------------

[](#javascript-helpers-overview)

Javascript helpers plugin provides two Twig variables and one filter.

### Twig variables

[](#twig-variables)

- `craft.jsHelpers.getMessages('locale_code')` - returns all static message translations as Twig array. By default it returns them for current site locale, but you can pass specific locale code as optional paramater to overwrite it.
- `craft.jsHelpers.outputMessages('array_name', 'locale_code')` - outputs static message translations into Template as Javascript array, at the end of `` tag. First parameter specifies Javascript array name. By default static message translations are returned for current site locale, but you can pass specific locale code as optional second paramater to overwrite it.

### Twig filters

[](#twig-filters)

- `jsVar('variable_name')` - outputs Twig variable as Javascript variable, at the end of `` tag. For example:

```
{{someTwigVariable|jsVar('some_js_variable')}}

```

Will output Javascript variable named `some_js_variable` into template, containing contents of `someTwigVariable`. Works both for variables with single value and for arrays or objests.

Hint: you can also achieve the same effect without this plugin, by using

```
{% do view.registerJsVar('some_js_variable', someTwigVariable, POS_END) %}

```

Disclaimer
----------

[](#disclaimer)

Brought to you by [Piotr Pogorzelski](http://craftsnippets.com)

Plugin icon by [Benjamin J sperry](https://iconscout.com/free-icon/javascript-15).

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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 ~435 days

Total

5

Last Release

719d ago

Major Versions

1.1.1 → 2.0.02022-06-18

2.0.0 → 3.0.02024-07-14

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/42622545?v=4)[Piotr Pogorzelski](/maintainers/piotrpog)[@piotrpog](https://github.com/piotrpog)

---

Top Contributors

[![piotrpog](https://avatars.githubusercontent.com/u/42622545?v=4)](https://github.com/piotrpog "piotrpog (7 commits)")

---

Tags

cmsCraftcraftcmscraft-pluginjavascript helpers

### Embed Badge

![Health badge](/badges/craftsnippets-javascript-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/craftsnippets-javascript-helpers/health.svg)](https://phpackages.com/packages/craftsnippets-javascript-helpers)
```

###  Alternatives

[verbb/formie

The most user-friendly forms plugin for Craft.

102393.6k69](/packages/verbb-formie)[wbrowar/guide

A CMS Guide for Craft CMS.

6154.7k1](/packages/wbrowar-guide)[verbb/vizy

A flexible visual editor field for Craft.

4250.4k](/packages/verbb-vizy)[verbb/hyper

A user-friendly links field for Craft.

24147.8k12](/packages/verbb-hyper)[verbb/footnotes

Adds a footnotes feature to CKEditor fields and Twig templates.

213.6k](/packages/verbb-footnotes)[verbb/events

A full-featured plugin for event management and ticketing.

2311.9k](/packages/verbb-events)

PHPackages © 2026

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