# Define methods for packages without importing

**URL:** <https://discourse.julialang.org/t/define-methods-for-packages-without-importing/55353>\
**Category:** Performance\
**Created:** [February 15, 2021, 9:57pm UTC](https://discourse.julialang.org/t/define-methods-for-packages-without-importing/55353 "2021-02-15T21:57:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [February 15, 2021, 9:57pm UTC](https://discourse.julialang.org/t/define-methods-for-packages-without-importing/55353/1 "2021-02-15T21:57:31Z")

</div>

Say that I got a package `Foo` and want my package to include some methods especially for handling DataFrames, and plots from Plots and Gadfly.

To do this, I could define something like

```julia
module Foo

import DataFrames
import Gadfly
import Plots

foo(x::DataFrames.DataFrame) = DataFrames.first(x, 5)
foo(x::Gadfly.Plot) = x
foo(x::Plots.Plot) = x

end # module

```

However, if an user now want to use `Foo`, the user has to install and precompile DataFrames, Plots and Gadfly even if the user has no intention of using any of these.

Is is possible to define the methods in Foo without importing the packages? (Or am I completely wrong, and would these imports not really affect the user?)

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [February 15, 2021, 10:01pm UTC](https://discourse.julialang.org/t/define-methods-for-packages-without-importing/55353/2 "2021-02-15T22:01:19Z")

</div>

Check out [https://github.com/JuliaPackaging/Requires.jl](https://github.com/JuliaPackaging/Requires.jl) which should do what you’re looking for.
